
#include <qtextcodec.h>

#include "CharacterProcessor.h"

CharacterProcessor::CharacterProcessor()
{
   TextCodec = QTextCodec::codecForName( "ISO 8859-1" );

   for( int i=0; i<255; i++ )
   {
      Transform[ i ] = i;
   }
   Transform[ 192 ] = 'A';
   Transform[ 193 ] = 'A';
   Transform[ 194 ] = 'A';
   Transform[ 195 ] = 'A';
   Transform[ 196 ] = 'A';
   Transform[ 197 ] = 'A';
//   Transform[ 198 ] = 65;
   Transform[ 199 ] = 'C';
   Transform[ 200 ] = 'E';
   Transform[ 201 ] = 'E';
   Transform[ 202 ] = 'E';
   Transform[ 203 ] = 'E';
   Transform[ 204 ] = 'I';
   Transform[ 205 ] = 'I';
   Transform[ 206 ] = 'I';
   Transform[ 207 ] = 'I';
   Transform[ 208 ] = 'D';
   Transform[ 209 ] = 'N';
   Transform[ 210 ] = 'O';
   Transform[ 211 ] = 'O';
   Transform[ 212 ] = 'O';
   Transform[ 213 ] = 'O';
   Transform[ 214 ] = 'O';
   Transform[ 216 ] = 'O';
   Transform[ 217 ] = 'U';
   Transform[ 218 ] = 'U';
   Transform[ 219 ] = 'U';
   Transform[ 220 ] = 'U';
   Transform[ 221 ] = 'Y';
   Transform[ 223 ] = 'S';

   Transform[ 224 ] = 'a';
   Transform[ 225 ] = 'a';
   Transform[ 226 ] = 'a';
   Transform[ 227 ] = 'a';
   Transform[ 228 ] = 'a';
   Transform[ 229 ] = 'a';
//   Transform[ 224 ] = 'S';
   Transform[ 231 ] = 'c';
   Transform[ 232 ] = 'e';
   Transform[ 233 ] = 'e';
   Transform[ 234 ] = 'e';
   Transform[ 235 ] = 'e';
   Transform[ 236 ] = 'i';
   Transform[ 237 ] = 'i';
   Transform[ 238 ] = 'i';
   Transform[ 239 ] = 'i';
   Transform[ 240 ] = 'o';
   Transform[ 241 ] = 'n';
   Transform[ 242 ] = 'o';
   Transform[ 243 ] = 'o';
   Transform[ 244 ] = 'o';
   Transform[ 245 ] = 'o';
   Transform[ 246 ] = 'o';
   Transform[ 248 ] = 'o';
   Transform[ 249 ] = 'u';
   Transform[ 250 ] = 'u';
   Transform[ 251 ] = 'u';
   Transform[ 252 ] = 'u';
   Transform[ 253 ] = 'y';
   Transform[ 255 ] = 'y';
}

CharacterProcessor::~CharacterProcessor()
{
}

QString CharacterProcessor::Simplify( const QString& string )
{
   int i;
   int length;
   QString rc;
   QCString tmp;
   unsigned char c;

   tmp = TextCodec->fromUnicode( string );
   length = tmp.length();

   for( i=0; i<length; i++ )
   {
      c = (unsigned char)tmp[ i ];
      c = Transform[ c ];
      rc.append( c );
   }

   return rc;
}


